package com.iptv.grape.domain;

import com.iptv.grape.bu.GrapeContext;
import com.iptv.grape.ui.control.ad.ListViewUI;
import com.iptv.grape.util.AppConstant;

import java.util.ArrayList;
import java.util.List;

public class ChannelBillTimeData implements IListViewShowItem{

    private Channel channel;
    private String text;
    private String code;

    public ChannelBillTimeData(Channel channel, String text, String code) {
        this.channel = channel;
        this.text = text;
        this.code = code;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public void setText(String text) {
        this.text = text;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public int getSort() {
        return 0;
    }

    @Override
    public String getText() {
        return text;
    }

    @Override
    public ListViewStyle getListViewStyle() {

        if(AppConstant.isTvStb()) {
            return new ListViewStyle(100, "channelTypeListItem",
                    "ChannelType", 9, 4, 0, 55, null);
        }
        else {
            return new ListViewStyle(100, "channelTypeListItem",
                    "ChannelType", 11, 5, 0, 55, null);
        }
    }

    @Override
    public List<IListViewShowItem> getChList() {
        List<IListViewShowItem> list = new ArrayList<IListViewShowItem>();
        List<ChannelBill> bills = GrapeContext.curGrapeContext().getBillList().getBillsByChannelID(channel.getKeyID(),this.code);
        if(bills != null && bills.size() > 0) {
            list.addAll(bills);
        }
        return list;
        //return new ArrayList<IListViewShowItem>();
    }

    @Override
    public void itemClick(List<IListViewShowItem> dataSouce, int pos, ListViewUI listViewUI) {

    }
}
